<?php
/**
 * Created by PhpStorm.
 * User: zd
 * Date: 2019/4/24
 * Time: 16:26
 */

namespace app\api\model;


class HandoverLog extends BaseModel
{
    protected $autoWriteTimestamp = true;

    /**
     * 与user和workuser中间表为一对多关系
     * @return \think\model\relation\HasMany
     */
    public function users(){
        return $this->hasMany('UserWorkuser','handover_id','id');
    }

    /**
     * 创建交接日志
     * @param $data
     * @return $this
     */
    public static function addLog($data){
        $log = new HandoverLog([
            'wu_id'  => $data['wu_id'],
            'num' =>  $data['num']
        ]);
        $log->save();
        return $log;
    }



}